<!--  -->
<template>
  <div id="main" class="mianaa">
    <div class="myporket">
      <!-- 暂无礼品 开始 -->
      <div
        style="margin-top: 90px;display: flex;flex-direction: column;align-items: center"
        v-if="liping"
      >
        <img
          style="height: 100px"
          src="@/assets/images/2020_dati/abcchina/nogift.png"
          alt=""
        />
        <p style="margin-top:20px;font-size: 17px">暂无积分</p>
      </div>
      <!-- 暂无礼品 结束 -->

      <!-- 礼品列表 开始 -->
      <div class="content" v-for="(item, index) in list" :key="index">
        <img class="contentimg" :src="gettupian(item)" alt="" />
        <div class="contenright">
          <p class="contenright_p">
            {{ item.content }}
          </p>
          <p class="contenright_p1">
            <span class="right_item">领取人：</span>{{ item.nickName }}
          </p>
          <p><span class="right_item">获得时间：</span>{{ timea }}</p>
          <p
            @click="getdesk(item)"
            v-if="
              item.award == '500元元初电子代金券' ||
                item.award == '农特康泉天然有机大米5kg' ||
                item.award == '盛洲2.5升食用油'
            "
            style="color: #fe0208;font-size: 13px;margin-top: 10px"
          >
            点击设置收货地址>>
          </p>
        </div>
      </div>
      <!-- 礼品列表 结束 -->
    </div>
  </div>
</template>

<script>
import { ActionSheet, Toast, Dialog, DialogAlert, vanCell } from 'vant'; //vant组件
import wx from 'weixin-js-sdk'; //微信SDK
import weixin from '@/components/wx/wx.js'; //微信自定义配置i
import moment from 'moment'; //日期插件
export default {
  components: { 'van-action-sheet': ActionSheet },
  data() {
    return {
      timea: '',
      paizi: false,

      list: [], //礼品列表
      liping: false //暂无礼品是否展示
    };
  },
  computed: {},
  watch: {},
  methods: {
    getdesk(item) {
      window.location.href =
        '/turntable/goAddress?source=abchina_turntable_2020&id=' + item.id;
    },
    getmygiftlist() {
      this.$http.post('/questionnaire/gift', {}).then(res => {
        if (res.data.code == '0') {
          // 列表
          this.list = res.data.object.list;
          console.log('列表： ', this.list);
          // 列表为空的话, 展示暂无礼品
          this.liping = this.list.length == 0 ? true : false;
        }
      });
    },
    gettupian(item) {
      this.timea = moment(item.createTime).format('YYYY[年]M[月]D[日] H[:]mm');
      if (item.content == '1积分') {
        return require('@/assets/images/2020_dati/abcchina/jf.png');
      } else if (item.content == '10积分') {
        return require('@/assets/images/2020_dati/abcchina/jf.png');
      } else if (item.content == '30积分') {
        return require('@/assets/images/2020_dati/abcchina/jf.png');
      } else if (item.content == '500元元初电子代金券') {
        return require('@/assets/images/2020_dati/abcchina/yuanchu.png');
      } else if (item.content == '农特康泉天然有机大米5kg') {
        return require('@/assets/images/2020_dati/abcchina/dami.png');
      } else if (item.content == '盛洲2.5升食用油') {
        return require('@/assets/images/2020_dati/abcchina/you.png');
      } else if (item.content == '20积分') {
        return require('@/assets/images/2020_dati/abcchina/jf.png');
      }
    }
  },
  created() {},
  mounted() {
    // 获取礼品列表
    this.getmygiftlist();
  }
};
</script>

<style lang="scss" scoped>
@import './goods.scss';
</style>
